import { qrcode, ResPage, ResultData, System } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import qs from "qs";

/**
 * @name 系统管理模块
 */

// 获取字典数据
export const getDicData = (typeName: string) => {
  return http.post<ResPage<System.ResDictList>>(PORT1 + `/Tools/GetDictList`, { name: typeName });
};

// 获取所有平台设置列表数据
export const getUserIntegralRulesInfo = () => {
  return http.get<any>(PORT1 + `/CoreCmsUserIntegralRules/GetInfoByContext`);
};

// 编辑积分规则信息
export const editUserIntegralRules = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsUserIntegralRules/DoEdit`, params);
};

// 编辑微餐厅设置
export const editCanteenRules = (params: {}) => {
  return http.post(PORT1 + `/corecmsstoresetting/doedit`, params);
};

// 获取用户列表
export const getUserList = (params: {}) => {
  return http.post<ResPage<System.ResUserList>>(PORT1 + `/SysUser/GetPageList`, qs.stringify(params));
};

// 新增用户
export const createUser = (params: {}) => {
  return http.post(PORT1 + `/SysUser/DoCreate`, params);
};

// 编辑用户
export const editUser = (params: {}) => {
  return http.post(PORT1 + `/SysUser/DoEdit`, params);
};

// 删除用户
export const deleteUser = (params: {}) => {
  return http.post(PORT1 + `/SysUser/DoDelete`, params);
};

// 获取角色列表
export const getRoleList = (params: {}) => {
  return http.post<ResPage<System.ResRoleList>>(PORT1 + `/SysRole/GetPageList`, qs.stringify(params));
};

// 编辑角色
export const editRole = (params: {}) => {
  return http.post(PORT1 + `/SysRole/DoEdit`, params);
};

// 创建角色
export const createRole = (params: {}) => {
  return http.post(PORT1 + `/SysRole/DoCreate`, params);
};

// 删除角色
export const deleteRole = (params: {}) => {
  return http.post(PORT1 + `/SysRole/DoDelete`, params);
};

// 设置权限
export const setSysMenu = (params: {}) => {
  return http.post(PORT1 + `/SysRole/DoSetSysMenu`, params);
};

// 获取权限菜单
export const getSysMenu = (params: {}) => {
  return http.post(PORT1 + `/SysRole/GetSysMenu`, params);
};

// 获取登录日志列表
export const getLoginRecordList = (params: {}) => {
  return http.post<ResPage<System.ResLoginRecordList>>(PORT1 + `/SysLoginRecord/GetPageList`, qs.stringify(params));
};

// 获取全局日志列表
export const getNLogRecordsList = (params: {}) => {
  return http.post<ResPage<System.ResNLogRecordsList>>(PORT1 + `/SysNLogRecords/GetPageList`, qs.stringify(params));
};

// 删除全局日志
export const deleteNLogRecords = (params: {}) => {
  return http.post(PORT1 + `/SysNLogRecords/DoDelete`, params);
};

// 获取定时任务列表
export const getTaskLogList = (params: {}) => {
  return http.post<ResPage<System.ResTaskLogList>>(PORT1 + `/SysTaskLog/GetPageList`, qs.stringify(params));
};

// 删除定时任务
export const deleteTaskLog = (params: {}) => {
  return http.post(PORT1 + `/SysTaskLog/DoDelete`, params);
};

// 获取用户操作日志列表
export const getUserOperationLogList = (params: {}) => {
  return http.post<ResPage<System.ResUserOperationLogList>>(PORT1 + `/SysUserOperationLog/GetPageList`, qs.stringify(params));
};

// 系统激活
export const doActivation = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStore/DoActivation`, qs.stringify(params));
};

//检查门店是否过期
export const isOutDate = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStore/IsOutDate`, params);
};

// 获取角色权限列表
export const getLoadMenuPageDictList = (params: {}) => {
  return http.post(PORT1 + `/SysMenuPagEdict/LoadMenuPageDictList`, params);
};

// 设置角色权限列表
export const setMenuPageDict = (params: {}) => {
  return http.post(PORT1 + `/SysMenuPageDict/SetMenuPageDict`, params);
};

// 获取用户常用功能列表
export const getUserCommonList = (params?: {}) => {
  return http.post(PORT1 + `/SysUserCommon/GetPageList`, params);
};

// 保存常用功能配置
export const setUserCommon = (params: {}) => {
  return http.post(PORT1 + `/SysMenuPageDict/SetUserCommon`, params);
};
// 加载配置用户常用功能
export const getUserMenuList = (params: {}) => {
  return http.post(PORT1 + `/SysMenuPageDict/GetUserCommonList`, params);
};

// 设置前端权限
export const setSysRolePos = (params: {}) => {
  return http.post(PORT1 + `/SysRole/SetSysRolePos`, params);
};

// 获取收银权限
export const getSysRolePos = (params: {}) => {
  return http.post(PORT1 + `/SysRole/GetSysRolePos`, params);
};

// 重置用户密码
export const resetPas = (params: {}) => {
  return http.post(PORT1 + `/SysUser/ResetPassword`, params);
};

// 获取首页统计数据
export const getStoreStatistic = (params?: {}) => {
  return http.post(PORT1 + `/CoreCmsStore/GetStoreStatistic`, params);
};

// 编辑页面设置
export const doDesign = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPages/DoDesign`, params);
};

// 获取页面设置
export const getDesignPageData = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPages/GetPageData`, params);
};

// 获取自定义页模板列表
export const getDesignPageList = (params: {}) => {
  return http.post<ResPage<System.DesignPageList>>(PORT1 + `/CoreCmsPages/GetPageList`, qs.stringify(params));
};

// 新增自定义页模板
export const createDesignPage = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPages/DoCreate`, params);
};

// 编辑自定义页模板
export const editDesignPage = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPages/DoEdit`, params);
};

// 删除自定义页模板
export const deleteDesignPage = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPages/DoEdit`, params);
};

// 页面设计模版接口
export const getHomePageTemplate = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPages/GetTempPage`);
};

// 获取短信签名信息
export const getMessageStoreAPI = () => {
  return http.post<System.RechargeData>(PORT1 + `/corecmsstore/GetStoreDetail`);
};

// 短信签名提交申请
export const submitApplyAPI = (params: {}) => {
  return http.post(PORT1 + `/corecmsstore/ApplySmsSign`, params);
};

// 充值链接
export const getQRcodeAPI = (params: {}) => {
  return http.post<string>(PORT1 + `/CoreCmsstore/RechargeSmsQRCode`, params);
};

// 拿支付回调
export const getPayStatusAPI = (params: {}) => {
  return http.post<boolean>(PORT1 + `/CoreCmsstore/TradeQuery`, params, { noLoading: true });
};
